package com.xingkeduo.business.user.rabbit;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.business.user.socket.WebsocketMessageResponse;
import com.xingkeduo.send.RabbitMqSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.xingkeduo.business.user.socket.WebsocketMessageResponse.MessageTypeEnum.WORKPAD;

/**MQ
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/6/5 10:55
 **/
@Slf4j
@Component
public class CraftsmanServiceMQ {

    @Autowired
    private RabbitMqSender rabbitMqSender;


    /**
     * 服务价格 和服务技能变动 通知下单屏
     *
     * @param storeId:
     * @param msg:
     * @return : java.lang.String
     * @author : gaozifeng
     * @date : 2019/6/5 11:03
     */
    public String sendCraftsmanService(String storeId, String msg) {
        try {
            rabbitMqSender.sendMessage("websocket_transfer_exchange", "websocket_transfer_key", JSON.toJSONString(new WebsocketMessageResponse<>(WORKPAD, storeId, null)));


        } catch (Throwable t) {
            log.info("服务价格 和服务技能变动 通知下单屏 消息失败"+t);
            return "error";
        }
//        rabbitMqSender.sendMessage("websocket_transfer_exchange", "websocket_transfer_key", JSON.toJSONString(new WebsocketMessageResponse<>(WORKPAD, order.getStoreId(), orderAnnounceMessageDto)));
        return "success";
    }
}
